﻿// -----------------------------------------------------------------------
// <copyright company="Christoph van der Fecht - VDsoft">
// This code can be used in commercial, free and open source projects.
// </copyright>
// -----------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace VDsoft.SeriesNewsReader.Model
{
	public enum Resolution
	{
		/// <summary>
		/// All resolutions.
		/// </summary>
		All,
		/// <summary>
		/// Resolution of 720p
		/// </summary>
		HDReady,
		/// <summary>
		/// Resolution of 1080p
		/// </summary>
		FullHD,
		/// <summary>
		/// All HD resolutions.
		/// </summary>
		HD,
		/// <summary>
		/// Default value.
		/// </summary>
		Unknown
	}

	/// <summary>
	/// A rss feed with all details.
	/// </summary>
	public class RssFeed : INotifyPropertyChanged, IComparable<RssFeed>
	{
		/// <summary>
		/// The Title.
		/// </summary>
		private string title = null;

		/// <summary>
		/// The Language.
		/// </summary>
		private string language = null;

		/// <summary>
		/// The Link.
		/// </summary>
		private Uri link = null;

		/// <summary>
		/// The Resolution.
		/// </summary>
		private Resolution resoution;

		/// <summary>
		/// Initializes a new instance of the <see cref="RssFeed"/> class.
		/// </summary>
		public RssFeed()
		{
		}

		/// <summary>
		/// Gets or sets the Title.
		/// </summary>
		public string Title
		{
			get
			{
				return this.title;
			}

			set
			{
				if (value == this.title)
				{
					return;
				}

				this.title = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the Language.
		/// </summary>
		public string Language
		{
			get
			{
				return this.language;
			}

			set
			{
				if (value == this.language)
				{
					return;
				}

				this.language = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the Link.
		/// </summary>
		public Uri Link
		{
			get
			{
				return this.link;
			}

			set
			{
				if (value == this.link)
				{
					return;
				}

				this.link = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the Resolution.
		/// </summary>
		public Resolution Resolution
		{
			get
			{
				return this.resoution;
			}

			set
			{
				if (value == this.resoution)
				{
					return;
				}

				this.resoution = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Occures when a property changed its value.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;

		/// <summary>
		/// Compares this instance of the <see cref="RssFeed"/> object with the provided one.
		/// </summary>
		/// <param name="other"><see cref="RssFeed"/> instance to compare.</param>
		/// <returns>True when the two instance are equal, otherwise false.</returns>
		public int CompareTo(RssFeed other)
		{
			if (other == null)
			{
				return 0;
			}

			return this.title.CompareTo(other.title);
		}

		/// <summary>
		/// Raises the <see cref="PropertyChanged"/> event.
		/// </summary>
		/// <param name="propertyName">Name of the property that changed its value.</param>
		private void RaisePropertyChanged([CallerMemberName]string propertyName = "")
		{
			if (this.PropertyChanged != null)
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
